<template>
  <edit v-bind="article_data"></edit>
</template>
<script>
import edit from '../../components/edit';
import ArtcileApi from './model/api.js';
export default {
  name: 'Update',
  data () {
    return {
      article_data: {},
    };
  },
  components: {
    edit,
  },
  created () {
    this.get_article();
  },
  methods: {
    get_article: async function () {
      const self = this;
      const id = this.$route.params.id;
      this.article_data = await ArtcileApi.getArticleById(id);
      this.$nextTick(function () {
        self.render_content();
      });
    },
    render_content: function () {
      const codeBlockList = document.querySelectorAll('p code');
      if (codeBlockList) {
        codeBlockList.forEach((block) => {
          window.hljs.highlightBlock(block);
        });
      }
    },
  },
};
</script>
<style src="./style.scss" lang="scss" scoped></style>
